<template>
  <div class="login_container">
    <div class="login_box">
      <!-- 头像 -->
      <div class="avatar_box">
        <img src="../assets/logo.png" alt="">
      </div>
      <!-- 表单 -->
      <el-form label-width="100"  class="login_form">
        <el-form-item>
          <el-input v-model="user.email" placeholder="邮箱"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="user.nickname"  placeholder="昵称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="user.password"  placeholder="密码"></el-input>
        </el-form-item>
        <el-form-item class="btns">
          <el-button type="info" @click="register()">注册</el-button>
        </el-form-item>
      </el-form>
      <div style="clear:both"></div>
    </div>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        user:{}
      }
    },
    methods: {
      register() {
        this.axios.post("/user/add",this.user).then((resp)=>{
          this.$message.success("注册成功！");
          this.$router.push("/");
        })
      }
    }
  }
</script>

<style scoped>
  .login_container{
    background-color: #409EFF;
    height: 50vh;
  }

  .login_box{
    width: 450px;
    height: 350px;
    background-color: #F2F0F0;
    border-radius: 3px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%)
  }

  .avatar_box{
    width: 130px;
    height: 130px;
    border: 1px solid #eee;
    border-radius: 50%;
    padding: 10px;
    box-shadow: 0 0 10px #ddd;
    position: absolute;
    left:50%;
    transform: translate(-50%,-50%);
    background-color: #fff;

  }

  .avatar_box img{
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #eee;
  }
  .login_form{
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
  }

  .btns{
    display: flex;
    justify-content:flex-end;
  }
</style>>

